package com.zlkj.pro.modular.api.controller;

import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import com.zlkj.pro.modular.api.model.dto.VersionDTO;
import com.zlkj.pro.modular.api.model.vo.VersionVO;
import com.zlkj.pro.modular.api.service.VersionService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import static com.zlkj.pro.core.consts.ProjectConstants.SERVICE_API_PREFIX;

/**
 * @author 孙铭泽
 * @date 2022/3/25
 * @time 18:43
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@ApiResource(name = "版本API", path = SERVICE_API_PREFIX + "/version")
public class VersionController {
    private final VersionService versionService;

    @GetResource(name = "检查版本更新", path = "/checkForVersionUpdate", requiredPermission = false, requiredLogin = false)
    public ResponseData checkForVersionUpdate(@Validated(VersionDTO.CheckForUpdate.class) VersionDTO versionDTO) {
        VersionVO restData = versionService.checkForVersionUpdate(versionDTO);
        return new SuccessResponseData(restData);
    }
}
